﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace studentPortal.Models
{
    public class UserRepository:IAccount
    {
        public user getUserFromPwd(String username, String pwd)
        {
            using(Database1Entities1 cx = new Database1Entities1())
            {
                return cx.users.First(x => x.username.Equals(username) && x.pwd.Equals(pwd));
            }
        }

        public void SaveLogin(user u)
        {
            using (Database1Entities1 cx = new Database1Entities1())
            {
                cx.users.Add(u);
                cx.SaveChanges();
            }
        }


        public user getUser(String u)
        {
            using (Database1Entities1 cx = new Database1Entities1())
            {
                return cx.users.First(x => x.username.Equals(u));
            }
        }


    }
}